﻿using Shop.RemoteModel.GoodsSpec.Model;
using Shop.StoreGatewayModular.Interface;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/goods/spec/{name}")]
    internal class GoodsSpecApi : ApiController
    {
        private readonly IGoodsSpecService _Service;

        public GoodsSpecApi (IGoodsSpecService service)
        {
            this._Service = service;
        }
        public bool SetSkuState (SkuStateSet state)
        {
            return this._Service.SetSkuState(state);
        }
        public void SyncSku ([NumValidate("shop.goods.id.error", 1)] long goodsId)
        {
            this._Service.SyncSku(goodsId);
        }
        public void DeleteSpec ([NumValidate("shop.spec.id.error", 1)] long id)
        {
            this._Service.DeleteSpec(id);
        }

        public GoodsSpecGroup[] GetSpecGroup ([NumValidate("shop.goods.id.error", 1)] long goodsId)
        {
            return this._Service.GetSpecGroup(goodsId);
        }
        public GoodsSpecGroup[] Sync ([NumValidate("shop.goods.id.error", 1)] long goodsId, [NumValidate("shop.category.id.error", 1)] long categoryId)
        {
            return this._Service.Sync(goodsId, categoryId);
        }
        public GoodsSpecSku[] GetSpecSku ([NumValidate("shop.goods.id.error", 1)] long goodsId)
        {
            return this._Service.GetSpecSku(goodsId);
        }

        public bool SetSpec (LongParam<GoodsSpecSet> set)
        {
            return this._Service.SetSpec(set.Id, set.Value);
        }

        public Dictionary<long, int> SetSpecSort (LongParam<int> set)
        {
            return this._Service.SetSpecSort(set.Id, set.Value);
        }

        public Dictionary<long, int> SetGroupSort (LongParam<int> set)
        {
            return this._Service.SetGroupSort(set.Id, set.Value);
        }


        public GoodsSpec AddSpec (GoodsSpecAdd datum)
        {
            return this._Service.AddSpec(datum);
        }

        public bool SetGroup (LongParam<string> set)
        {
            return this._Service.SetGroup(set.Id, set.Value);
        }

        public long AddGroup (SpecGroupAdd datum)
        {
            return this._Service.AddGroup(datum);
        }

        public void DeleteGroup ([NumValidate("shop.spec.group.id.error", 1)] long id)
        {
            this._Service.DeleteGroup(id);
        }

        public void DeleteSkuSpec (LongParam<long[]> param)
        {
            this._Service.DeleteSkuSpec(param.Id, param.Value);
        }
    }
}
